package com.example.redis.config;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author:xuecx
 * @descript:<p> </p>
 * @date:2019/4/24
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(beanName.equals("redisTemplate")){
            System.out.println("开始初始化redisTemplate");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if(beanName.equals("redisTemplate")){
            System.out.println("结束初始化redisTemplate");
        }
        return bean;
    }
}
